package com.airticketbooking.controller.manager;

import com.airticketbooking.common.domain.PageDTO;
import com.airticketbooking.common.domain.PageQuery;
import com.airticketbooking.common.domain.Result;
import com.airticketbooking.vo.SeatVO;
import com.airticketbooking.service.SeatService;
import com.github.pagehelper.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;



@RequestMapping("/air/manager/Seat")
@RestController
@Api(tags = "座位相关接口")
@RequiredArgsConstructor
@Slf4j
public class MSeatController {

	//	座位分页查询接口
	private final SeatService seatService;

	@GetMapping("/page")
	@ApiOperation(value = "查询航班座位分页信息")
	public Result<PageDTO<SeatVO>> list(PageQuery pageQuery, Integer classId, Integer scheduleId) {
		log.info("查询航班座位分页信息");
		Page<SeatVO> pageVo = seatService.list(pageQuery, classId, scheduleId);
		PageDTO<SeatVO> seatVOPageDTO = new PageDTO<>();
		seatVOPageDTO.setTotal(pageVo.getTotal());
		seatVOPageDTO.setList(pageVo.getResult());

		return Result.ok(seatVOPageDTO);
	}

	//	根据座位id查询座位信息接口
	@GetMapping("getById/{seatId}")
	@ApiOperation(value = "根据座位id查询座位信息")
	public Result<SeatVO> getById(@PathVariable("seatId") Integer seatId) {
		log.info("根据座位id查询座位信息");
		SeatVO seatVO = seatService.getById(seatId);
		return Result.ok(seatVO);
	}


}
